//
//  YWTempMission.m
//  maintain
//
//  Created by Kyo on 16/3/4.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWTempMission.h"
#import "YWCommonTool.h"
#import "YWHandler.h"

@implementation YWTempMission
+ (NSArray *)mj_ignoredPropertyNames
{
    return @[@"isExpand",@"toUserIds",@"observerIds"];
}

+ (NSDictionary*)mj_replacedKeyFromPropertyName
{
    return @{ @"tempMissionId" : @"id",
              @"fromUser" : @"releaseUser"
              };
}
+ (NSDictionary*)mj_objectClassInArray
{
    return @{ @"imagesList" : @"YWPatrolPicture",
              @"attachmentList" : @"YWattachment",
              @"observers" : @"YWHandler",
              @"executors" : @"YWHandler"};
}
- (void)mj_keyValuesDidFinishConvertingToObject{
    if (self.executors.count>0) {
        self.toUserIds = [YWCommonTool handlerIdsWithHandlerArray:self.executors];
    }
    
    NSMutableString *atUserName = [[NSMutableString alloc] init];
    [self.observers enumerateObjectsUsingBlock:^(YWHandler*  _Nonnull handler, NSUInteger idx, BOOL * _Nonnull stop) {
        if (atUserName.length && idx!=0) {
            [atUserName appendString:@","];
        }
        [atUserName appendString:[@(handler.uniqueId) stringValue]];
    }];
    self.observerIds = [NSString stringWithFormat:@"%@",atUserName];
}
@end
